home *** CD-ROM | disk | FTP | other *** search
/ USA Bestseller / USA BESTSELLER Vol 1-95 (Hepp-Computer)(1995).iso / e004 / aliases < prev    next >
Text File  |  1994-10-12  |  10KB  |  260 lines

  1. :
  2. :                     ALIASES -- 4DOS Sample Alias File
  3. :
  4. :
  5. :     The aliases in this file are designed to give you some examples of
  6. :     how 4DOS aliases can be used and the power they have.  It is not
  7. :     intended to be an exhaustive list, and many of these may not be
  8. :     appropriate for your needs.  But they should give you a feel for how
  9. :     to use aliases to help get your work done.
  10. :
  11. :     CAUTION:  These aliases are EXAMPLES.  We do NOT promise that they
  12. :     will work properly when run on your system.  They are simply intended
  13. :     to show what's possible and give you a feel for how to write your
  14. :     own set of aliases.  You may find some of them useful, but others
  15. :     may fail or have unintended effects when they are run on a system
  16. :     other than the one they were designed for.
  17. :
  18. :     This file is designed to be loaded with an ALIAS /R command, for
  19. :     example:
  20. :
  21. :               alias /r aliases
  22. :
  23. :     You can also load aliases from a batch file, but ALIAS /R is much
  24. :     faster.  See the manual for more details on loading aliases.
  25. :
  26. :     We suggest you put your standard aliases are in a self-contained
  27. :     file like this one which can be invoked from AUTOEXEC.  That
  28. :     way the file can also be re-invoked after it is edited, to re-
  29. :     install the aliases.
  30. :
  31. :
  32. :
  33. :     The next few aliases set up some directory commands that provide
  34. :     shorthand ways to view the directory in several different formats
  35. :     (see the DIR command in the manual for more details).
  36. :
  37. :     Note that none of these aliases has any arguments specified (%1,
  38. :     %2, etc.).  This means that all arguments on the actual command line
  39. :     will be appended to the alias text.  For example:
  40. :
  41. :             d2 x*
  42. :
  43. :     is equivalent to:
  44. :
  45. :             dir /2pv x*
  46. :
  47. :     and:
  48. :
  49. :             d2 x* y* z*
  50. :
  51. :     is equivalent to:
  52. :
  53. :             dir /2pv x* y* z*
  54. :
  55. d2 dir /2pv
  56. de dir /oe
  57. dir *dir /p
  58. wh*ereis dir /dp
  59. :
  60. :     The last two commands above demonstrate the use of an asterisk to
  61. :     terminate alias expansion and to shorten the name of an alias.
  62. :
  63. :     In the first case, if the command were defined as:
  64. :
  65. :             alias dir dir/p
  66. :
  67. :     it would generate an alias loop error.  The inclusion of the "*"
  68. :     makes 4DOS terminate alias expansion for that command, which
  69. :     allows the redefinition of a command with specific switch settings.
  70. :     In this case "dir" is redefined as "dir/p", which will cause
  71. :     directories to be displayed with a pause at the end of each page.
  72. :
  73. :     The "whereis" command demonstrates truncation of an alias name.
  74. :     The * is placed after the last required character in the name, so
  75. :     the "whereis" command can be entered as "wh", "whe", "wher",
  76. :     "where", "wherei", or "whereis".
  77. :
  78. :
  79. :     The following aliases are more shorthand:  DD and DU (directory
  80. :     down and directory up) for pushd and popd, DX (shows only the
  81. :     subdirectorie, L for list, etc.
  82. :
  83. dd pushd
  84. du popd
  85. dx *dir /mwad
  86. l list
  87. clr mode mono
  88. :
  89. :     Aliases can also be used to modify the behavior of some internal
  90. :     commands.  The two examples below show how you can force DELETE and
  91. :     MOVE to prompt before execution.  If you need to use the unprompted
  92. :     command, use the leading asterisk ("*DEL").
  93. del*ete *del /p
  94. move *move /r
  95. :
  96. :
  97. :     The next aliases show how some commands can be enhanced.  Instead of
  98. :     always prompting you for new values, TIME and DATE can simply report
  99. :     the current information.
  100. :
  101. date echo Today is %_dow %_date
  102. time echo The time is %_time
  103. :
  104. :
  105. :     Here's what the next few aliases do:
  106. :
  107. :             more:   Uses 4DOS's LIST /S as a substitute for the DOS MORE
  108. :                     command.  Note the use of the * to allow the command
  109. :                     to be entered as MO, MOR, or MORE
  110. :
  111. :             ff:     Uses the 4DOS FFIND command to find a file anywhere
  112. :                     in the current directory or any of its subdirectories,
  113. :                     for example:
  114. :
  115. :                             ff *.dat
  116. :
  117. :             fft:    Like FF, but assumes that the second and following
  118. :                     arguments are text to look for within the files.  For
  119. :                     example, to find all .DAT files with the string "hello
  120. :                     Barbara" in them you could use this command:
  121. :
  122. :                             fft *.dat hello barbara
  123. :
  124. :             sdel:   Allows you to select files for deletion from a subset
  125. :                     of files as specified in the command argument.  For
  126. :                     example:
  127. :
  128. :                             sdel *.obj
  129. :
  130. :                     will allow you to select files to delete from a list
  131. :                     of all .obj files.  (See the SELECT command in the
  132. :                     manual for more details).
  133. :
  134. :             up:     Moves "up" in the directory tree, i.e. to the parent
  135. :                     directory.
  136. :
  137. :             ov:     Moves "over" in the directory tree, to another subdi-
  138. :                     rectory which has the same parent as the current
  139. :                     directory.
  140. :
  141. mo*re list /s
  142. ff ffind /s
  143. fft ffind /s /t"%2&" %1 
  144. sdel select del (%1)
  145. up cd ..
  146. ov cd ..\%1
  147. :
  148. :     The next two aliases show how arguments can be passed to commands.
  149. :     In both cases the argument given when the alias is invoked is passed
  150. :     to the program at the appropriate place in its command string.
  151. :
  152. :
  153. lp lpr -u %1 >lpt1
  154. ps d:\peri\ps /t:%1 /e:4
  155. :
  156. :     The next few aliases demonstrate several things.  Some use the
  157. :     command separator character ^ to include multiple commands in
  158. :     the alias.  ND2 uses the "&&" (AND) operator so that the second
  159. :     command is only executed if the first was succcessful.  The last
  160. :     two (PC and BACK) use the alias called IN to do their job.  In
  161. :     fact IN was designed for "internal" use by other aliases in this
  162. :     file, though it could be used elsewhere as well.  Note that, while
  163. :     PX is set up before it is referenced in other aliases, this is not
  164. :     really necessary, because any command in one alias which refers to
  165. :     another is handled when the alias is invoked, not when it is set
  166. :     up with the alias command.
  167. :
  168. :     Here's what each alias does:
  169. :
  170. :             nd:     Creates a new directory below the current directory,
  171. :                     then changes to it.
  172. :
  173. :             nd2:    Attempts to creates the specified directory on any
  174. :                     drive, then changes to it if the creation was
  175. :                     successful.
  176. :
  177. :             w:      Saves the current directory, changes to the ws
  178. :                     directory on drive c:, runs the ws program using
  179. :                     the first argument on the command line, and
  180. :                     restores the original directory when done.
  181. :
  182. :             zap:    Deletes all the .bak files in the current directory,
  183. :                     then does a wide directory listing.
  184. :
  185. :             in:     "Pushes" a different directory, executes a command,
  186. :                     including all of the arguments on the command line,
  187. :                     and then goes back to the original directory.  See
  188. :                     PUSHD, POPD, and Alias Parameters in the manual for
  189. :                     more details.
  190. :
  191. :             pc:     Changes to the \comm directory on drive c:, runs
  192. :                     the program called pcomm, then returns to the
  193. :                     drive and directory in use when the command was
  194. :                     executed.
  195. :
  196. :             back:   Changes to the \backup directory on drive d:, runs
  197. :                     the program called tape, then returns to the previous
  198. :                     drive and directory.
  199. :
  200. nd md %1^cd %1
  201. nd2 md %1 && *cdd %1
  202. w pushd c:\wp^ws %1^popd
  203. zap del *.bak^dir /w
  204. in pushd %1^%2&^popd
  205. pc in c:\comm pcomm
  206. back in d:\backup tape
  207. :
  208. :     The following aliases make use of the %& argument.  This argument
  209. :     means "all of the arguments on the command line".  For example:
  210. :
  211. :             zap2 *.bak *.lst *.bk!
  212. :
  213. :     expands to:
  214. :
  215. :             erase *.bak *.lst *.bk!^chkdsk^dir /w
  216. :
  217. :     The last of the three aliases below uses the %@eval function to
  218. :     create a command-line calculator, by simply passing all arguments
  219. :     on the command line to the function.
  220. :
  221. zap2 erase %&^chkdsk^dir /w
  222. ed edit %&^del *.bak
  223. cal*c echo The answer is:  %@eval[%&]
  224. :
  225. :     The following two aliases, taken from the manual, show how to 
  226. :     combine alias with keystack to invoke a program and pass parameters
  227. :     to it.  See the manual for details on what they do.  Note that the
  228. :     0s in the keystack strings simulate an empty keyboard buffer; the
  229. :     13s are carriage returns.
  230. :
  231. 321 keystack 0 13 0 13 0 13 0 13 0 13 "/fr" 0 "%1" 13^123
  232. drpt pushd c:\data^keystack "use times index times" 13 "report form timerep to print" 13 "quit" 13^dbase^popd
  233. :
  234. :
  235. :     The following aliases show the use of IFF in aliases.  The first
  236. :     redefines SET so that it displays the environment variables with a
  237. :     /P if no parameters are given, or processes the SET if parameters
  238. :     are specified.  The second checks whether the argument is a directory;
  239. :     if so it deletes the files in the directory and then removes the
  240. :     directory.  If not, it gives an error message.
  241. :
  242. set iff "%1"=="" then ^ *set /p ^ else *set %& ^ endiff
  243. zap iff isdir %1 then ^ *del %1 ^ *rd %1 ^ else ^ beep ^ echo Not a directory! ^ endiff
  244. :
  245. :     You can also assign any alias to a keystroke to save a lot of typing.
  246. :     Check your manual for the proper way to express keynames.
  247. :
  248. :     The following examples reassign the following keys:
  249. :
  250. :        F5:        wide directory
  251. :           Ctrl-F1    clear screen
  252. :           Shift-F10: "EXIT" + ENTER  (useful then "shelling out")
  253. :           Alt-F1:    invokes another HELP program
  254. :
  255. @f5 dir /w
  256. @Ctrl-F1 cls
  257. @shift-f10 exit r
  258. @alt-f1 c:\dos\help
  259.  
  260.